<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>人员审核</title>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/common/i/favicon.ico"/>
    <meta name="apple-mobile-web-app-title" content="人员审核"/>
    <link rel="stylesheet" href="Css/amazeui.min.css"/>
    <link rel="stylesheet" href="Css/app.css"/>
    <script src="Scripts/api.js"></script>
    <link rel="stylesheet" href="Css/font_783249_3hfdb7m5w0j.css">
    <script src="Scripts/jquery.min.js"></script>
    <script src="Scripts/font_783249_e5yrsf08rap.js"></script>
    <script>
        BASE_URL = 'https://demo.yiovo.com/';
        STORE_URL = 'index.php?s=/store';
    </script>
</head>

<body data-type="">
<div class="am-g tpl-g">

    <!-- 内容区域 start -->
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-cf">人员审核列表</div>
                        </div>
                        <div class="widget-body am-fr">
                            <!-- 工具栏 -->
                            <div class="page_toolbar am-margin-bottom-xs am-cf">
                                <form class="toolbar-form" action="">
                                    <input type="hidden" name="s" value="/store/goods/index">
                                    <div class="am-u-sm-12 am-u-md-3" >
                                        <div class="am-form-group" id="topsetting">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a class="am-btn am-btn-default am-btn-success"
                                                   href="/admin/UserExamine.html">
                                                    返回
                                                </a>
                                            </div>
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a class="am-btn am-btn-default am-btn-success"
                                                   href="/admin/ExamineSuccessList.html">
                                                    查看通过审核列表
                                                </a>
                                            </div>

                                        </div>

                                    </div>

                                    <div class="am-u-sm-12 am-u-md-9">

                                        <div class="am fr">

                                            <div class="am-form-group am-fl">

                                                <div class="am-input-group am-input-group-sm tpl-form-border-form">

                                                    <input type="text" class="am-form-field" name="userid"
                                                           placeholder="请输入用户ID"
                                                           value="">
                                                    <div class="am-input-group-btn">
                                                        <button class="am-btn"
                                                                type="submit">搜索</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>

                            <div class="am-scrollable-horizontal am-u-sm-12">
                                <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                                    <thead>
                                    <tr>
                                        <th>审核ID</th>
                                        <th>用户ID</th>
                                        <th>申请类型</th>
                                        <th>审核图片</th>
                                        <th>审核状态</th>
                                        <th>描述</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id = "ExamineList">

                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-lg-12 am-cf">
                                <div class="am-fr"> </div>
                                <div class="am-fr pagination-total am-margin-right">
                                </div>
                            </div>
                            <div id  ="pageitem" class="am-u-lg-12 am-cf">

                            </div>
                        </div>
                    </div>
                </div>
            </div>

    <!-- 内容区域 end -->

</div>

<script>

    var isFind = false;
    var getParam = function(name){
        var search = document.location.search;
        var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
        var matcher = pattern.exec(search);
        var items = null;
        if(null != matcher){
            try{
                items = decodeURIComponent(decodeURIComponent(matcher[1]));
            }catch(e){
                try{
                    items = decodeURIComponent(matcher[1]);
                }catch(e){
                    items = matcher[1];
                }
            }
        }
        return items;
    };
    var userid = getParam('userid');

    var pagenum = getParam('pagenum');
    if(pagenum==null)
        pagenum = 1;

    var ImagePath = null;
    var getimageback = function (wxhelpdata) {
        ImagePath =   wxhelpdata;
    };
    var addImage = function (aid) {
        document.getElementById('imageimg'+aid).src = ImagePath;
        document.getElementById('imagehref'+aid).href = ImagePath;
        ImagePath =null;
    }


    var getfailListcallback = function (wxhelpdata) {

            for(var n=0;n<wxhelpdata['rows'].length;n++)
            {
                var eid = wxhelpdata['rows'][n]['id'];
                var euid = wxhelpdata['rows'][n]['userId'];
                var etype = wxhelpdata['rows'][n]['type'];
                var estate = wxhelpdata['rows'][n]['state'];
                var etypeint = parseInt(etype);
                var estateint = parseInt(estate);
                var types = null;
                var states = null;
                if(etypeint==0)
                {
                    types = "医生";
                }else if(etypeint==1)
                {
                    types = "护士";
                }else if(etypeint==2)
                {
                    types = "企业";

                }else{
                    types = "手工艺者";
                }
                if(estateint==0)
                {
                    states = "<p class=\"item-title\"  style=\"color:blue\" >待审核</p>";
                }else if(estateint==1)
                {
                    states = "<p class=\"item-title\"  style=\"color:green\" >审核成功</p>";
                }else{
                    states = "<p class=\"item-title\"  style=\"color:red\" >审核失败</p>";
                }

                var tmep_html ="<tr class=\"examineItem"+eid+"\">\n" +
                    "                                        <td class=\"am-text-middle\">"+eid+"</td>\n" +
                    "                                        <td class=\"am-text-middle\">"+euid+"</td>\n" +
                    "                                        <td class=\"am-text-middle\">\n" +
                    "                                            <p class=\"item-title\">"+types+"</p>\n" +
                    "                                        </td>\n" +
                    "                                        <td class=\"am-text-middle\">\n" +
                    "                                        <a title=\"点击查看大图\" id=\"imagehref"+eid+"\" href=\"\" target=\"_blank\">\n" +
                    "                                            <img width=\"50\" height=\"50\" id=\"imageimg"+eid+"\" alt=\"审核图片\" src=\"\">\n" +
                    "                                        </a>\n" +
                    "                                        </td>\n" +
                    "                                        <td class=\"am-text-middle\">\n" + states  +
                    "                                        </td>\n" +
                    "                                        <td class=\"am-text-middle\">\n" +
                    "                                            <div class=\"tpl-table-black-operation\">\n" +
                    "                                                <a class=\"tpl-table-black-operation-green\" href=\"/admin/pollingExamineMessage.html?examineid="+eid+"\">\n" +
                    "                                                    查看详情\n" +
                    "                                                </a>\n" +
                    "                                            </div>\n" +
                    "                                        </td>\n" +
                    "                                        <td class=\"am-text-middle\">\n" +
                    "                                            <div class=\"tpl-table-black-operation\">\n" +
                    "\n" +
                    "                                            </div>\n" +
                    "                                        </td>\n" +
                    "                                    </tr>";
                $("#ExamineList").append(tmep_html);

                getExamineImageById(eid,getimageback);
                addImage(eid);
            }
        var allnum = parseInt(wxhelpdata['total']);
        var pageallnum = parseInt(Math.ceil(allnum/10));
        pagenum = parseInt(pagenum);

        var pagehtml = "<div class=\"am-fr\">\n" +
            "                            <ul class=\"pagination\">";
        if(pagenum==1){
            pagehtml+="<li class=\"disabled\">\n" +
                "                                    <span>«</span>\n" +
                "                                </li>\n" +
                "                                <li class=\"active\">\n" +
                "                                    <span>1</span>\n" +
                "                                </li>";
        }
        else if(pagenum<=5){
            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+(pagenum-1)+"\""+">«</a>\n" +
                "                                </li>";
            for(var i=1;i<pagenum;i++){
                pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+i+"\""+">"+i+"</a>\n" +
                    "                                </li>";
            }
            pagehtml+="<li class=\"active\">\n" +
                "                                    <span>"+pagenum+"</span>\n" +
                "                                </li>";
        }
        else{
            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+(pagenum-1)+"\""+">«</a>\n" +
                "                                </li>";
            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum=1\""+">1</a>\n" +
                "                                </li>";
            pagehtml+="<li class=\"disabled\"><span>...</span>\n" +
                "                                </li>";
            for(var i=pagenum-3;i<pagenum;i++){
                pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+i+"\""+">"+i+"</a>\n" +
                    "                                </li>";
            }
            pagehtml+="<li class=\"active\">\n" +
                "                                    <span>"+pagenum+"</span>\n" +
                "                                </li>";
        }

        if(pagenum == pageallnum){
            pagehtml+="<li class=\"disabled\">\n" +
                "                                    <span>»</span>\n" +
                "                                </li>";
        }
        else if(pageallnum-4<pagenum){

            for(var i=pagenum+1;i<=pageallnum;i++){
                pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+i+"\""+">"+i+"</a>\n" +
                    "                                </li>";
            }
            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+(pagenum+1)+"\""+">»</a>\n" +
                "                                </li>";

        }
        else{
            for(var i=pagenum+1;i<=pagenum+3;i++){
                pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+i+"\""+">"+i+"</a>\n" +
                    "                                </li>";
            }
            pagehtml+="<li class=\"disabled\"><span>...</span>\n" +
                "                                </li>";

            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+pageallnum+"\""+">"+pageallnum+"</a>\n" +
                "                                </li>";
            pagehtml+="<li><a href=\"/admin/ExamineFailList.html?pagenum="+(pagenum+1)+"\""+">»</a>\n" +
                "                                </li>";
        }
        pagehtml+="</ul>\n" +
            "                        </div>\n" +
            "                        <div class=\"am-fr pagination-total am-margin-right\">\n" +
            "                            <div class=\"am-vertical-align-middle\">总记录："+allnum+"</div>\n" +
            "                        </div>";
        $("#pageitem").append(pagehtml);

        };

    if(userid!=null)
    {

        window.location.href = "/admin/UserExamine.html?userid="+userid;
    }
    else{
        getExamineList(pagenum,2,getfailListcallback);

    }

    var agreecallback = function (id) {
        $(".examineItem"+id).remove();
    };


    function agreeExamine(id) {
        layer.confirm('确定同意该审核吗？'
            , {title: '友情提示'}
            , function (index) {
                agreeExamineApi(id,agreecallback(id));
                layer.close(index);
            },function ()
            {
                layer.close();
            });

    }



    function dateToStr(datetime){

        var year = datetime.getFullYear();
        var month = datetime.getMonth()+1;//js从0开始取
        var date = datetime.getDate();
        var hour = datetime.getHours();
        var minutes = datetime.getMinutes();
        var second = datetime.getSeconds();

        if(month<10){
            month = "0" + month;
        }
        if(date<10){
            date = "0" + date;
        }
        if(hour <10){
            hour = "0" + hour;
        }
        if(minutes <10){
            minutes = "0" + minutes;
        }
        if(second <10){
            second = "0" + second ;
        }

        var time = year+"-"+month+"-"+date+" "+hour+":"+minutes+":"+second; //2009-06-12 17:18:05
        //alert(time);
        return time;
    }

</script>
<script src="Scripts/layer.js"></script>
<script src="Scripts/jquery.form.min.js"></script>
<script src="Scripts/amazeui.min.js"></script>
<script src="Scripts/webuploader.html5only.js"></script>
<script src="Scripts/art-template.js"></script>
<script src="Scripts/app.js"></script>
<script src="Scripts/file.library.js"></script>
</body>

</html>